<template>
  <div>
    <template v-for="job in jobs" :key="job">
      <job-recomment-list-item :job="job" style="margin: 10px 0" />
    </template>
    <template v-if="jobs.length === 0">
      <el-empty description="暂无数据"></el-empty>
    </template>
  </div>
</template>

<script>
import JobRecommentListItem from "@/components/JobRecommentListItem.vue";
import mitter from "../../../plugins/mitter";
export default {
  components: { JobRecommentListItem },
  data: () => ({
    jobs: [],
  }),
  created() {
    this.fetchData("");
    mitter.on("search", (data) => {
      this.fetchData(data);
    });
  },
  methods: {
    fetchData(kw) {
      let url = "/job/home";
      if (kw) {
        url += "?kw=" + kw
      } 
      this.axios.get(url).then((res) => {
        this.jobs = res.data.data;
      });
    },
  },
};
</script>

<style>
</style>